package vip.source.pattern.part16.improve.service.impl;

import vip.source.pattern.part16.improve.framework.Configuration;
import vip.source.pattern.part16.improve.service.SqlSession;
import vip.source.pattern.part16.improve.service.SqlSessionFactory;

/**
 * 公众号 | 开源字节
 * 开源社区 | https://bbs.sourcebyte.vip
 */
public class DefaultSqlSessionFactory implements SqlSessionFactory {

    private final Configuration configuration;

    public DefaultSqlSessionFactory(Configuration configuration) {
        this.configuration = configuration;
    }

    @Override
    public SqlSession openSession() {
        return new DefaultSqlSession(configuration.connection, configuration.mapperElement);
    }

}
